package cn.fl.spl.controller;

import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.logger.eum.LogOperEnum;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.fl.spl.service.ISplCiCfgLogService;
import cn.fl.spl.vo.SplCiCfgLogVO;
import fl.constant.facade.framework.constant.BusinessIdConstant;
import fl.spl.facade.framework.constant.SplSystemConstant;
import fl.spl.facade.framework.enums.BasisDataRelDescEnum;
import fl.spl.facade.spl.api.ISplCommBlackListApiService;
import fl.spl.facade.spl.condition.SplCommBlackListQC;
import fl.spl.facade.spl.constant.SplCommBlackListConstant;
import fl.spl.facade.spl.constant.SplInfoConstant;
import fl.spl.facade.spl.dto.SplCommBlackListDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSONObject;

import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.product.service.ISplInfoService;
import cn.fl.product.vo.SplInfoVO;
import cn.fl.spl.vo.SplCiCfgVO;
import fl.spl.facade.spl.condition.SplCiCfgQC;

/**
 * @Description: 供应商征信配置表 控制层
 */
@Controller
@RequestMapping("/spl/splcicfg")
public class SplCiCfgController extends BaseController {

	/**
	 * SplCiCfg 服务层BEAN
	 */
	 // TODO 2018-08-22 16:55:48 暂时注释
	 //	@Autowired
//	private ISplCiCfgService splCiCfgService;
	/**
	 * 供应商基础服务BEAN
	 */
	@Autowired
	private ISplInfoService splInfoService;

	@Autowired
	private ISplCommBlackListApiService splCommBlackListApiService ;

	@Autowired
	private ISplCiCfgLogService splCiCfgLogService;

	/**
	 * 到列表页面
	 */
	@RequestMapping(value = "/toListPage.do", method = { RequestMethod.GET})
	public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {

		ModelAndView view = new ModelAndView("spl/splCiCfg/splCiCfgList");
		
		return view;
	}
	
	/**
	 * 到新增修改页面
	 */
	@RequestMapping(value = "/toAddPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response) {

		ModelAndView view = new ModelAndView("spl/splCiCfg/splCiCfgAdd");
		
		return view;
	}

	/**
	 * 到修改页面
	 */
	@RequestMapping(value = "/toModifyPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {

		String id = request.getParameter("id");
		ModelAndView view = new ModelAndView("spl/splCiCfg/splCiCfgModify");
		view.addObject("id", id);
		return view;
	}
	
	/**
	 * 到详情页面
	 */
	@RequestMapping(value = "/toDetailPage.do", method = { RequestMethod.GET})
	public ModelAndView toDetailPage(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		ModelAndView view = new ModelAndView("spl/splCiCfg/splCiCfgDetail");
		view.addObject("id", id);
		
		return view;
	}

	/**
	 * 初始化列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initList(HttpServletRequest request, HttpServletResponse response) {

		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String searchName = request.getParameter("demo.name");
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}

		SplCiCfgQC qc = new SplCiCfgQC();
		if (StringUtils.isNotEmpty(searchName)) {
			//TODO SOMTHING
		}
		page.setCondition(qc);

		//TODO SOMETHING
		Pager pager = new Pager();//this.splCiCfgService.searchListPage(page);
		List<SplCiCfgVO> list = (List<SplCiCfgVO>) pager.getResultList();
		ListPageVO<SplCiCfgVO> listPage = new ListPageVO<SplCiCfgVO>(list, pager.getTotalCount());
		return listPage;
	}
	
	/**
	 * 新增
	 */
	@RequestMapping(value = "/add.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object add(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String name = request.getParameter("name");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "新增成功!");
		SplCiCfgVO entity = null;
		try {
			entity = new SplCiCfgVO();
			//TODO ADD PARAM
			 // TODO 2018-08-22 16:55:48 暂时注释
			//Long id = this.splCiCfgService.add(entity);
			//result.setData(id);
			//BaseLogUtils.info(logger, "add", "新增数据.[id="+id+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("系统错误,请联系管理员!");
		}
		return result;
	}

	/**
	 * 修改
	 */
	@RequestMapping(value = "/modify.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modify(HttpServletRequest request, HttpServletResponse response) throws BaseException {

		String id = request.getParameter("id");
		//String name = request.getParameter("name");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "修改成功!");
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("数据不存在!");
			return result;
		}
		SplCiCfgVO entity = null;
		try {
			entity = new SplCiCfgVO();
			entity.setId(Long.valueOf(id));
			//entity.setName(name);
			//TODO ADD PARAM
			 // TODO 2018-08-22 16:55:48 暂时注释
			//boolean success = this.splCiCfgService.modify(entity);
			//if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("修改失败!");
			//}
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("系统错误,请联系管理员!");
		}

		return result;
	}

	/**
	 * 删除数据
	 */
	@RequestMapping(value = "/removeById.do", method = {RequestMethod.POST })
	@ResponseBody
	public DataResultVO removeById(HttpServletRequest request, HttpServletResponse response) throws BaseException {

		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "删除成功!");
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("主键不能为空!");
			return result;
		}
		try {
		 // TODO 2018-08-22 16:55:48 暂时注释
			//this.splCiCfgService.removeById(Long.valueOf(id));
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("系统错误,请联系管理员!");
		}
		
		return result;
	}

	/**
	 * 得到一条记录
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getById.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getById(HttpServletRequest request, HttpServletResponse response) throws BaseException {

		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "操作成功!");
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("主键不能为空!");
			return result;
		}
		
		try {
		 // TODO 2018-08-22 16:55:48 暂时注释
			//SplCiCfgVO vo = this.splCiCfgService.selectById(Long.valueOf(id));
//			if(null == vo){
//				result.setSuccess(BaseConstant.IS_YESNO_NO);
//				result.setInfo("数据不存在!");
//				BaseLogUtils.info(logger, "getById", "获取数据,数据不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
//			}
//			result.setData(vo);
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("系统错误,请联系管理员!");
		}
		
		return result;
	}
	
	/**
	 * 保存查征信配置
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	  // TODO 2018-08-22 16:55:48 暂时注释
	/*@RequestMapping(value = "/saveCiCfg.do", method = { RequestMethod.GET , RequestMethod.POST})
	@ResponseBody
	public Object saveCiCfg(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		Long startTm = System.currentTimeMillis();
		String methodName = "saveCiCfg";
		BaseLogUtils.info(logger, methodName, "根据主键获取对象.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
		
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "操作成功!");
		
		String splId = request.getParameter("splId");// 供应商ID
		String splNm = request.getParameter("splNm");// 供应商名称
		String isAuthCrdChk = request.getParameter("isAuthCrdChk");// 是否有权查询征信
		String limChkTms = request.getParameter("limChkTms");// 当前剩余总查征信次数
		String isEnable = request.getParameter("isEnable");// 是否启用征信规则
		
		if (StringUtils.isEmpty(splId)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("供应商ID不能为空");
			BaseLogUtils.info(logger, methodName, "供应商ID为空", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		if (StringUtils.isEmpty(isAuthCrdChk)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("请选择是否有权查征信");
			BaseLogUtils.info(logger, methodName, "是否有权查征信状态为空", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		if (StringUtils.isEmpty(isEnable)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("请选择是否启用征信规则");
			BaseLogUtils.info(logger, methodName, "是否启用征信规则为空", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		//String livSwitch = request.getParameter("livSwitch");//前置征信活体开关
		//String crdLoaSwitch = request.getParameter("crdLoaSwitch");//前置征信授权书开关
		boolean success = false;
		SplInfoVO vo = new SplInfoVO();
		try {
			if(StringUtils.isNotEmpty(isAuthCrdChk)){
				vo.setIsAuthCrdChk(Integer.valueOf(isAuthCrdChk));
				
				//vo.setLivSwitch(Integer.valueOf(livSwitch));//前置征信活体开关
				//vo.setCrdLoaSwitch(Integer.valueOf(crdLoaSwitch));//前置征信授权书开关
				
				if (StringUtils.isNotEmpty(limChkTms) && isEnable.equals("0")) {
					vo.setLimChkTms(Integer.valueOf(limChkTms));
				}
				vo.setId(Long.valueOf(splId));
				success = this.splInfoService.modifySplInfo(vo);
				BaseLogUtils.info(logger, methodName, "保存征信开关数据::"+success+".DATA:"+JSONObject.toJSONString(vo), CurrentThreadContext.getCurrentUserName());
			} else {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("必须设置是否有权查征信");
				BaseLogUtils.info(logger, methodName, "未设置--是否有权查询征信--", CurrentThreadContext.getCurrentUserName());
				return result;
			}
			if (success) {
				//修改供应商征信配置
				SplCiCfgQC ciCfgCondition = new SplCiCfgQC();
				ciCfgCondition.setSplId(Long.valueOf(splId));
				List<SplCiCfgVO> ciCfgList = this.splCiCfgService.searchList(ciCfgCondition);
				if (CollectionUtils.isNotEmpty(ciCfgList)) {
					// 如果最新记录不为空,则修改该条记录
					SplCiCfgVO ciCfgVo = ciCfgList.get(0);
					ciCfgVo.setIsAuthCrdChk(Integer.valueOf(isAuthCrdChk));// 是否有权查询征信
					//ciCfgVo.setAvgChkTms(Long.valueOf(limChkTms));// 每日可查征信次数
					if (StringUtils.isNotEmpty(limChkTms) && isEnable.equals("0")) {
						ciCfgVo.setLimChkTms(Long.valueOf(limChkTms));// 剩余总查询次数
					}
					ciCfgVo.setIsEnable(Integer.valueOf(isEnable));// 是否启用查征信规则
					ciCfgVo.setMdfTm(new Date());
					ciCfgVo.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
					boolean modify = this.splCiCfgService.modify(ciCfgVo);
					result.setSuccess(BaseConstant.IS_YESNO_YES);
					BaseLogUtils.info(logger, methodName, "修改征信配置" + modify, CurrentThreadContext.getCurrentUserName());
				} else {
					//如果最新记录为空,则添加新记录
					SplCiCfgVO splCiCfgVO = new SplCiCfgVO();
					splCiCfgVO.setSplId(Long.valueOf(splId));
					splCiCfgVO.setSplNm(splNm);
					splCiCfgVO.setIsAuthCrdChk(Integer.valueOf(isAuthCrdChk));// 是否有权查询征信
					if (StringUtils.isNotEmpty(limChkTms) && isEnable.equals("0")) {
						splCiCfgVO.setLimChkTms(Long.valueOf(limChkTms));// 剩余总查询次数
					}
					splCiCfgVO.setIsEnable(Integer.valueOf(isEnable));// 是否启用查征信规则
					splCiCfgVO.setCrtTm(new Date());
					splCiCfgVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
					splCiCfgVO.setIsNew(BaseConstant.IS_YESNO_YES);
					Long add = this.splCiCfgService.add(splCiCfgVO);
					result.setSuccess(BaseConstant.IS_YESNO_YES);
					BaseLogUtils.info(logger, methodName, "添加征信配置--id : " + add, CurrentThreadContext.getCurrentUserName());
				}
			}
		} catch (NumberFormatException e) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(e.getMessage());
			BaseLogUtils.info(logger, methodName, "保存征信开关数据::EORRO.DATA:"+e, CurrentThreadContext.getCurrentUserName());
			return result;
		} catch (BaseException e) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(e.getMessage());
			BaseLogUtils.info(logger, methodName, "保存征信开关数据::EORRO.DATA:"+e, CurrentThreadContext.getCurrentUserName());
			return result;
		} catch (Exception e) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(e.getMessage());
			BaseLogUtils.info(logger, methodName, "保存征信开关数据::EORRO.DATA:"+e, CurrentThreadContext.getCurrentUserName());
			return result;
		}
		result.setData(success);
		
		Long endTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, methodName, "根据主键获取对象.耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());

		return result;
	}*/

	/**
	 * 刷新每周或者每天的查征信定时任务
	 */
	@RequestMapping(value = "/refreshLimChk.do", method = { RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public JSONObject refreshLimChk(HttpServletRequest request, HttpServletResponse response) {
		String reqTyp = request.getParameter("reqTyp");
		String splId = request.getParameter("splId");

		JSONObject jsonObject = new JSONObject();
		jsonObject.put("status","success");
		jsonObject.put("info", "刷新征信定时任务成功");
		if(StringUtils.isEmpty(reqTyp)){
			jsonObject.put("status","false");
			jsonObject.put("info", "刷新征信定时任务失败，请求类型reqTyp不能为空！");
			return jsonObject ;
		}
		try{
		 // TODO 2018-08-22 16:55:48 暂时注释
			//boolean flag= this.splCiCfgService.runLimChkJobOneTime(reqTyp,StringUtils.isEmpty(splId) ? null: Long.valueOf(splId));
			//if(!flag){
				jsonObject.put("status","false");
				jsonObject.put("info", "刷新征信定时任务失败!reqTyp = "+reqTyp);
			//}
		}catch (BaseException be){
			jsonObject.put("status","false");
			jsonObject.put("info", "刷新征信定时任务失败,reqTyp= "+reqTyp+"be："+be.getMessage());
			BaseLogUtils.newWebLogger("刷新征信定时任务失败,业务异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(be)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
			be.printStackTrace();
		}catch (Exception ex){
			jsonObject.put("status","false");
			jsonObject.put("info", "刷新征信定时任务失败，reqTyp = "+reqTyp+"ex："+ex.getMessage());
			BaseLogUtils.newWebLogger("刷新征信定时任务失败,系统异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.error(LogExceptionEnum.COMMON_CODE_0099);
			ex.printStackTrace();
		}
		return jsonObject;
	}
	
	/**
	 * 保存查征信配置
	 * 2018-08-22 16:14:41 暂时启用
	 * 		殷烈-征信规则上线后次接口作废(上线时间未定)
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/saveCiCfg1.do", method = { RequestMethod.GET , RequestMethod.POST})
	@ResponseBody
	public Object saveCiCfg1(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "操作成功!");
		
		String splId = request.getParameter("splId");// 供应商ID
		String isAuthCrdChk = request.getParameter("isAuthCrdChk");// 是否有权查询征信
		String limChkTms = request.getParameter("limChkTms");// 每日可查征信次数
		String isAuthCrdChkB = request.getParameter("isAuthCrdChkB");// 是否有权查询征信
		String limChkTmsB = request.getParameter("limChkTmsB");// 每日可查征信次数

		
		if (StringUtils.isEmpty(splId)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("供应商ID不能为空");
			BaseLogUtils.newWebLogger("供应商ID为空").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0001);

			return result;
		}
		SplCommBlackListQC splCommBlackListQC = new SplCommBlackListQC();
		splCommBlackListQC.setIsDel(BaseConstant.IS_YESNO_NO);
		splCommBlackListQC.setIsValid(BaseConstant.IS_YESNO_YES);
		splCommBlackListQC.setUsrTypCd(BasisDataRelDescEnum.SPL.getTableSimpleNm());
		splCommBlackListQC.setBusTypCd(SplCommBlackListConstant.SHOP_APP_CHECKCREDIT_BLACK_LIST_BUS_TYP);
		splCommBlackListQC.setUsrId(Long.valueOf(splId));
		List<SplCommBlackListDTO> splCommBlackListDTOS = this.splCommBlackListApiService.searchSplCommBlackListDTOs(splCommBlackListQC);
		if(CollectionUtils.isNotEmpty(splCommBlackListDTOS)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("该经销商无权限保存征信状态.");
			BaseLogUtils.newWebLogger("因经销商在黑名单中,无权限保存征信状态").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0001);

			return result;
		}
		if (StringUtils.isEmpty(isAuthCrdChk)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("请选择是否有权查征信");
			BaseLogUtils.newWebLogger("是否有权查征信状态为空").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0001);

			return result;
		}
		if (StringUtils.isEmpty(limChkTms)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("请配置差征信次数");
			BaseLogUtils.newWebLogger("查征信次数为空").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0001);

			return result;
		}
		
		boolean success = false;
		SplInfoVO vo = new SplInfoVO();
		try {
			if(StringUtils.isNotEmpty(isAuthCrdChk)){
				vo.setIsAuthCrdChk(Integer.valueOf(isAuthCrdChk));// 是否有权查征信开关
				vo.setLimChkTms(Integer.valueOf(limChkTms));// 每日可查征信次数
				vo.setId(Long.valueOf(splId));// 供应商ID
				success = this.splInfoService.modifySplInfo(vo);

				SplCiCfgLogVO ciCfgLogVO = new SplCiCfgLogVO();
				boolean needAdd = false;
				if (StringUtils.isNotEmpty(isAuthCrdChkB) && !isAuthCrdChkB.equals(isAuthCrdChk)) {
					ciCfgLogVO.setIsAuthCrdChkB(Integer.parseInt(isAuthCrdChkB));
					ciCfgLogVO.setIsAuthCrdChk(Integer.parseInt(isAuthCrdChk));
					needAdd = true;
				}
				if (StringUtils.isNotEmpty(limChkTmsB) && !limChkTmsB.equals(limChkTms)) {
					ciCfgLogVO.setLimChkTmsB(Integer.parseInt(limChkTmsB));
					ciCfgLogVO.setLimChkTms(Integer.parseInt(limChkTms));
					needAdd = true;
				}
				if (needAdd) {
					ciCfgLogVO.setDataId(Long.parseLong(splId));
					ciCfgLogVO.setDataTabNm(SplInfoConstant.PRD_SPL_TAB_NAME);
					ciCfgLogVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
					ciCfgLogVO.setCrtTm(new Date());
					ciCfgLogVO.setIsDel(BaseConstant.IS_YESNO_NO);
					ciCfgLogVO.setIsNew(BaseConstant.IS_YESNO_YES);

					this.splCiCfgLogService.addAndUpdateOld(ciCfgLogVO);
				}
				BaseLogUtils.newWebLogger("保存征信开关数据::"+success+".DATA:"+JSONObject.toJSONString(vo))
						.setLogOperType(LogOperEnum.RESP)
						.setSysCd(CurrentThreadContext.getCurrentSysCd())
						.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
						.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
						.setWarning(false)
						.info();
			} else {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("必须设置是否有权查征信");
				BaseLogUtils.newWebLogger("未设置--是否有权查询征信--").setLogOperType(LogOperEnum.RESP)
						.setSysCd(CurrentThreadContext.getCurrentSysCd())
						.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
						.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
						.setWarning(false)
						.warn(LogExceptionEnum.COMMON_CODE_0002);

				return result;
			}
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newWebLogger("保存征信开关数据,业务异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newWebLogger("保存征信开关数据,系统异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.error(LogExceptionEnum.COMMON_CODE_0099);
		}
		result.setData(success);
		
		return result;
	}

}

